using UnityEngine;
using System.Collections;

public class Battery : Item {
	
	public BatteryLevelFlashlight batteryLevelScript;
	
	public Battery() {
		name = "Battery";
		description = "Charges flashlight for 50%.";
	}
	
	public void changeBatteryFlashlight() {
		batteryLevelScript.batteryLevel += Game.game.getFlashlightMaxPower() * 0.5f;
		// Easy has additional battery level, incremental
		if (Game.game.difficulty != Game.DIFFICULTY_EASY && batteryLevelScript.batteryLevel > Game.game.getFlashlightMaxPower()) {
			batteryLevelScript.batteryLevel = Game.game.getFlashlightMaxPower();	
		}
		if (audio != null)  {
			batteryLevelScript.wasFlashlightOnWhenBatteryChanged = batteryLevelScript.flashlight.enabled;
			batteryLevelScript.flashlight.enabled = false;
			audioSource.PlayOneShot(audio);
			batteryLevelScript.batteryPickedUp = true;
		} else {
			Debug.Log("Warning! audio is null!");		
		}	
	}
	
	public override void onLeftClick() {
		changeBatteryFlashlight();
		Game.inventory.items[index] = null;
	}
}
